package com.springcontext.factorybean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

@Component
public class FactoryBeanDemo implements FactoryBean {

  Logger logger = LoggerFactory.getLogger(this.getClass());

  /**
   *
   * 使用场景，如果Student 是第三方组件中的 依赖。要纳入到 当前的spring 容器中。FactoryBean 的方法。把改依赖项 纳入到 spring 容器中
   *
   */
  @Override
  public Object getObject() throws Exception {
    logger.warn("init student");
    return new Student();
  }

  @Override
  public Class<?> getObjectType() {
    return Student.class;
  }
}
